
$(function () {
  var e = new Behave({
      textarea: $(".main textarea").get(0),
      replaceTab: true,
      softTabs: true,
      tabSize: 2,
      autoOpen: true,
      overwrite: true,
      autoStrip: true,
      autoIndent: true,
      fence: false

  });
  return $('input[type="button"]').click(function () {
    var t = $('<div><pre class="javascript"></pre><i class="iconfont icon-clipboard" title="复制到剪贴板"></i><i class="iconfont icon-delete" title="删除"></i></div>'),
         e = $(".main textarea");
  "" !== e.val() && (t.find("pre").html(e.val()),
    hljs.highlightBlock(t.find("pre").get(0)),
    $(".main").append(t));
  var i = t.find("i.icon-delete"),
         n = t.find("i.icon-clipboard");
  i.click(function () { t.remove()  }),
         n.click(function () {
           var e = t.find("pre"),
         i = document.createRange();
         i.selectNode(e[0]),
         window.getSelection().addRange(i),
         document.execCommand("copy"),
         window.getSelection().removeAllRanges()

         })

  }), e

});
